[id].vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div id="newsList">
  3. <!-- 头部 -->
  4. <templateHead></templateHead>
  5. <!-- 菜单 -->
  6. <templateMenu></templateMenu>
  7. <div v-for="(item,index) in templateData" :key="index">
  8. <!--1.广告通栏-->
  9. <div v-if="item.sectorName=='adSector'">
  10. <templateAd :skinId="skinId" :adData="adData" :adTag="item.ad.ad_tag"></templateAd>
  11. </div>
  12. <!-- 2.搜索列表 -->
  13. <div v-if="item.sectorName=='searchListSector'">
  14. <templateSearch :skinId="skinId" :templateData="item.componentList"></templateSearch>
  15. </div>
  16. </div>
  17. <!-- 底部 -->
  18. <templateFoot></templateFoot>
  19. </div>
  20. </template>
  21. <script setup lang="ts">
  22. //0.加载全局模板组件 start---------------------------------------->
  23. //0.1 全局通栏
  24. import templateHead from '@/components/template/sector/head/1200x200/1.vue'
  25. import templateMenu from '@/components/template/sector/menu/1200x130/1.vue'
  26. import templateFoot from '@/components/template/sector/foot/1200x580/1.vue'
  27. //0.2.1 广告组件
  28. import templateAd from '@/components/template/sector/body/ad/1200x90/1.vue'
  29. //0.2.2 搜索组件
  30. import templateSearch from '@/components/template/sector/body/search/list/1200x1300/1.vue'
  31. //0.加载全局模板组件 end---------------------------------------->
  32. //1.获得基本信息单元 start---------------------------------------->
  33. //1.1获得页面依赖
  34. import { ref, onMounted } from 'vue';
  35. //1.2获得pinia源
  36. import { useTemplateBaseStore } from '@/stores/templateBase'
  37. const templateBaseStore:any = useTemplateBaseStore()
  38. //1.3获得该页的皮肤id - 在每个组件中也是同样的获得方法
  39. const skinId = ref<number>(0)
  40. const websiteId = ref<number>(0)
  41. //1.4获得站点基本信息
  42. const responseStatus:any = await requestDataPromise('/web/getWebsiteAllinfo', {
  43. method: 'GET',
  44. query: {
  45. 'link_textnum':24,
  46. 'link_imgnum':18,
  47. 'link_footnum':4
  48. },
  49. });
  50. if (responseStatus.code == 200) {
  51. if(responseStatus.data.website_foot.foot_info.status == 1){
  52. //网站模板已停用,直接转入404页面
  53. navigateTo('/error?findPage=index')
  54. }else{
  55. //0.3.1设置站点基本信息
  56. templateBaseStore.setWebSiteInfo(responseStatus.data)
  57. websiteId.value = responseStatus.data.website_head.id;//获得网站id
  58. //0.3.2设置皮肤id
  59. skinId.value = templateBaseStore.webSiteInfo.website_foot.foot_info.template_id;
  60. console.log("当前的网站id:"+responseStatus.data.website_head.id)
  61. //0.3.3设置seo信息
  62. let seoTitle = templateBaseStore.webSiteInfo.website_head.title;
  63. let seoDescription = templateBaseStore.webSiteInfo.website_head.description;
  64. let seoKeywords = templateBaseStore.webSiteInfo.website_head.keywords;
  65. let seoSuffix = templateBaseStore.webSiteInfo.website_head.suffix;
  66. let seoName = templateBaseStore.webSiteInfo.website_head.website_name;
  67. useHead({
  68. title: seoTitle + "_" + seoSuffix,
  69. meta: [
  70. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  71. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
  72. ]
  73. });
  74. }
  75. }
  76. //1.获得基本信息单元 end---------------------------------------->
  77. //2.页面数据 start---------------------------------------->
  78. //2.1获得页面数据
  79. const response = await requestDataPromise('/client/indexData', {
  80. method: 'POST',
  81. body: {
  82. 'website_id':websiteId.value,
  83. 'getpage':'search'
  84. },
  85. });
  86. //页面数据
  87. const templateData = response.data.template.search;
  88. //是否启用搜索功能
  89. templateBaseStore.setIsSearch(response.data.isSearch)
  90. console.log(templateData)
  91. //广告数据
  92. const adData = ref<any[]>([]);
  93. adData.value.push(response.data.ad.top)
  94. for(let item of response.data.ad.aloneArticle){
  95. adData.value.push(item)
  96. }
  97. templateBaseStore.setAdList(adData.value)
  98. //2.页面数据 end---------------------------------------->
  99. </script>
  100. <style lang="less" scoped>
  101. </style>